<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
		<div class="btn-group hidden-xs" id="toolbar" role="group">
			<a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="beautyflower:order:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.removeAll()" shiro:hasPermission="beautyflower:order:remove">
				<i class="fa fa-trash-o"></i> 删除
			</a>
		</div>
			
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('beautyflower:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('beautyflower:order:remove')}]];
        var detailsFlag = [[${@permission.hasPermi('beautyflower:order:details')}]];
        var order_type = [[${@dict.getType('order_type')}]];
        var prefix = ctx + "beautyflower/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "订单 ",
                search: false,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '' 
				},
				{
					field : 'orderNumber', 
					title : '订单编号' 
				},
				{
					field : 'orderTime', 
					title : '下单时间' 
				},
				{
					field : 'loanAmount', 
					title : '借款金额' 
				},
				{
					field : 'memberName',
					title : '借款人' 
				},
				{
					field : 'mobile', 
					title : '借款手机号' 
				},
				{
					field : 'status', 
					title : '当前状态' ,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(order_type, value);
                    }
				},
				// {
				// 	field : 'orderType',
				// 	title : '订单类型'
				// },
				{
					field : 'orderPeriods', 
					title : '订单期数' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-info btn-xs ' + detailsFlag + '" href="#" onclick="details(\'' + row.id + '\')" style="margin-left: 4px"><i class="fa fa-eye"></i>详情</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + detailsFlag + '" href="#" onclick="notice(\'' + row.id + '\',\'' + row.orderNumber + '\',\'' + row.memberId + '\')" style="margin-left: 4px"><i class="fa fa-bell-o"></i>通知</a> ');
                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        /*用户管理-详情*/
        function details(id) {
            var url = prefix + '/details/' + id;
            $.modal.openFill("用户详情", url);
        }

        // 还款提醒
        function notice(orderId, orderNumber, memberId) {
            $.modal.open("消息提醒", ctx + "beautyflower/order/notice?id=" + orderId + "&orderNumber=" + orderNumber + "&memberId=" + memberId,420,280);
        }
    </script>
</body>
</html>